/*
 * @Author: your name
 * @Date: 2022-01-18 07:37:18
 * @LastEditTime: 2022-01-18 08:32:44
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \my-site\src\store\index.js
 */
import Vue from "vue"
import Vuex from "vuex"
import getAbout from "@/api/about.js"
import getProject from "@/api/project.js"
Vue.use(Vuex)

const store = new Vuex.Store({
    state:{
        aboutData:"",
        projectData:[]
    },
    mutations:{
        setAboutData(state, payload){
            state.aboutData = payload
        },
        setProjectData(state, payload){
            state.projectData = payload
        },
    },
    actions:{
        async fetchAbout(ctx){
            const resp = await getAbout()
            ctx.commit("setAboutData", resp)
        },
        async fetchProject(ctx){
            const resp = await getProject()
            ctx.commit("setProjectData", resp)
        }
    }
})

export default store